//
//  MainDefaulSearchVC_V4_Sub.mMainDefaulSearchVC_V4_Sub.h
//  ZITHER
//
//  Created by weixin on 2018/11/19.
//  Copyright © 2018 weixn. All rights reserved.
//

#import "MainDefaulSearchVC_V4_Sub.h"
#import "MainDefaulSearchVC_V4_Sub_TbvCell.h"
#import "GoodsModel.h"

@interface MainDefaulSearchVC_V4_Sub ()

@property (nonatomic,strong)MainDefaulSearchVC_V4_Sub_Tbv * tbv;

@property (nonatomic,strong)NSMutableArray * arrMGoods;//型号数据


@end

@implementation MainDefaulSearchVC_V4_Sub

- (void)viewDidLoad {
    
    [super viewDidLoad];
    
    [self setNav];
    
    [self setUI];

}

-(void)setState:(STRefreshState)State{
    _State = State;
    [self setUI];
}

-(void)setNav{
    [self.baseNavigationView setHiddenNav:YES VC:self];

    [self.baseNavigationView NavigationBarStyle:1];
    self.baseNavigationView.navViewStyle.title.text = @"";
    self.baseNavigationView.navViewStyle.leftBtn.hidden = YES;
    self.baseNavigationView.leftButton1.hidden = YES;
    self.baseNavigationView.bottomLineView.hidden = YES;
}

-(void)setUI{
 
    
    
    [self.view addSubview:self.tbv];
    //遮盖cell会超出tbv部分
    UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, TabbarHeight+15)];
    view.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:view];
    [self.view addSubview:self.lab];

    [self.tbv mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.lab.mas_bottom).offset(0);
        make.left.right.equalTo(self.view).offset(0);
        make.bottom.equalTo(self.view).offset(-50);
    }];
    
    
    [self.lab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.view).offset(TabbarHeight-5);
        make.left.right.equalTo(self.view).offset(15);
    }];
    
    BaseBtn *btn = [[BaseBtn alloc]initWithFrame:CGRectMake(15, 0, kScreenW-30, 40)];
    [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [btn setTitle:@"取消" forState:UIControlStateNormal];
    [self.view addSubview:btn];
    btn.backgroundColor = [UIColor whiteColor];
    
    @weakify(self);
    [[btn rac_signalForControlEvents:(UIControlEventTouchUpInside)] subscribeNext:^(__kindof UIControl * _Nullable x) {
        @strongify(self);
        [self.navigationController popViewControllerAnimated:YES];
    }];
    
    
    [btn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.tbv.mas_bottom).offset(0);
        make.left.right.equalTo(self.view).offset(0);
        make.height.mas_equalTo(40);
    }];
    
}



-(BaseLab *)lab{
    if (!_lab) {
        _lab = [[BaseLab alloc]initializeFrame:CGRectMake(0, 0, 0, 1) text:@"搜索条件   >   系列" font:1 textColor:[UIColor colorWithHex:@"333333"] isBold:NO numberOfLines:0];
        _lab.font = [UIFont fontWithName:@"PingFangSC-Medium" size:17];
        _lab.backgroundColor = [UIColor whiteColor];
    }
    return _lab;
}

-(MainDefaulSearchVC_V4_Sub_Tbv *)tbv{
    if (!_tbv) {
        NSInteger index = 0;
        if (self.State == STRefreshStateNormal) {
            index = 0;
        }else{
            index = 1;
        }
        _tbv = [[MainDefaulSearchVC_V4_Sub_Tbv alloc]initializeFrame:CGRectMake(0, 0, 0, 1) isMj:index isEstimatedRowHeight:YES addRegisterNib:@[@"MainDefaulSearchVC_V4_Sub_TbvCell"]];
        _tbv.State = self.State;
        @weakify(self);
        [_tbv setBlcok:^(NSDictionary * _Nonnull dic) {
            @strongify(self);
            if (self.blcok) {
                self.blcok(dic);
            }
        }];
        [_tbv setBlcokGoods:^(NSDictionary * _Nonnull dic, goodVOsModel * _Nonnull model) {
            @strongify(self);
            if (self.blcokGoods) {
                self.blcokGoods(dic, model);
            }
        }];
        _tbv.tableHeaderView = [[BaseView alloc]initWithFrame:CGRectMake(0, 0, 0, 20)];
        [_tbv setShadowType1WithColor:[UIColor defaultShadowColor] offset:CGSizeMake(0, 3) opacity:1 radius:2];
        
    }
    return _tbv;
}

-(void)setModel:(searchOptionVOsModel *)model{
    _model = model;
    self.tbv.model = model;
    [self.tbv reloadData];
}


-(void)setDic:(NSDictionary *)dic{
    _dic = dic;
    self.tbv.dic = dic;
}



-(void)setModelSub:(MainDiscernSelectWatchSeriesModelSub *)modelSub{
    _modelSub = modelSub;
    self.tbv.modelSub = modelSub;
}
@end
